# go_demo  WFRgQPSKV?A1zNBE
from peewee import *
from user_srv.settings import settings


class BaseModel(Model):
    class Meta:
        database = settings.DB


class User(BaseModel):
    GENDER_CHOICE = (
        ("female", "女"),
        ("male", "男")
    )
    ROLE_CHOICE = (
        (2, "管理员"),
        (1, "普通用户")
    )
    mobile = CharField(max_length=11, index=True, unique=True, verbose_name="手机号码")
    password = CharField(max_length=100, verbose_name="密码")
    nick_name= CharField(max_length=20, null=True, verbose_name="昵称")
    head_url= CharField(max_length=200, null=True, verbose_name="头像")
    birthday = DateField(null=True, verbose_name="生日")
    address = CharField(max_length=200, null=True,verbose_name="住址")
    desc = TextField(null=True,verbose_name="个人简介")
    gender = CharField(max_length=6, choices=GENDER_CHOICE, null=True, verbose_name="性别")
    role = IntegerField(default=1, choices=ROLE_CHOICE, verbose_name="用户角色")


if __name__ == "__main__":
    settings.DB.create_tables([User])
    #
    # import hashlib
    # m = hashlib.md5()
    # m.update(b"123456")
    # print(m.hexdigest())